package com.sogoodsoft.web.communicate;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;
import org.springside.modules.utils.web.struts2.Struts2Utils;

import com.sogoodsoft.entity.common.Smslog;
import com.sogoodsoft.service.common.SmslogService;
import com.sogoodsoft.web.CrudActionSupport;
import com.sogoodsoft.web.WebConstants;

@Namespace("/sms")
@Results({ @Result(name = CrudActionSupport.RELOAD, location = "smslog.action", type = "redirect") })
public class SmslogAction extends CrudActionSupport < Smslog > {

    /**
	 * 
	 */
    private static final long serialVersionUID = -2497146405981278037L;

    private Long id;

    private Smslog smslog;

    private SmslogService sSer;

    private Page < Smslog > page = new Page < Smslog >(WebConstants.PAGE_SIZE);

    @Override
    public String delete() throws Exception {
        prepareModel();
        sSer.delete(smslog);
        addActionMessage(getText("delete.success"));
        return RELOAD;
    }

    @Override
    public String input() throws Exception {
        return INPUT;
    }

    @Override
    @SuppressWarnings("unchecked")
    public String list() throws Exception {
        logger.debug("查询短信列表");
        page = sSer.keyQuery("list.smslog", page, Struts2Utils.getRequest().getParameterMap());
        return SUCCESS;
    }

    @Override
    protected void prepareModel() throws Exception {
        if (id != null) {
            smslog = sSer.get(id);
        } else {
            smslog = new Smslog();
        }
    }

    @Override
    public String save() throws Exception {
        return null;
    }

    @Override
    public Smslog getModel() {
        return smslog;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Smslog getSmslog() {
        return smslog;
    }

    public void setSmslog(Smslog smslog) {
        this.smslog = smslog;
    }

    public SmslogService getsSer() {
        return sSer;
    }

    @Autowired
    public void setsSer(SmslogService sSer) {
        this.sSer = sSer;
    }

    public Page < Smslog > getPage() {
        return page;
    }

    public void setPage(Page < Smslog > page) {
        this.page = page;
    }

}
